﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;

namespace TowerDefender.Graphics
{
    public class MapManager
    {
        public static Grid CreateMap(Window window, Entities.Map map)
        {
            Grid g = new Grid();
            window.Content = g;
            g.Width = window.Width * 0.9;
            g.Height = window.Height * 0.8;
            g.Background = Brushes.Green;

            for (int i = 0; i < map.Width; i++)
            {
                var c = new ColumnDefinition();
                g.ColumnDefinitions.Add(c);
            }
            for (int j = 0; j < map.Length; j++)
            {
                var r = new RowDefinition();
                g.RowDefinitions.Add(r);
            }


            foreach (var step in map.MapPath.Steps)
            {
                Rectangle r = new Rectangle();

                r.Fill = new SolidColorBrush(Colors.Gray);
                r.SetValue(Grid.ColumnProperty, step.X - 1);
                r.SetValue(Grid.RowProperty, step.Y - 1);
                g.Children.Add(r);
            }
            return g;
        }
    }
}
